package com.actions.bluetoothbox2.util;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RatingBar;
import android.widget.TextView;

import com.actions.bluetoothbox2.R;

import java.util.List;

/**
 * Created by liuyong on 2018/6/21.
 */

public class SchoolReportAdapter extends BaseAdapter {

    Context context;
    List<SchoolReportInfo> list;

    public SchoolReportAdapter(Context context, List<SchoolReportInfo> list) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (null == view) {
            view = LayoutInflater.from(context).inflate(R.layout.item_school_report, viewGroup, false);
        }

        TextView tv_time = (TextView) view.findViewById(R.id.tv_time);
        RatingBar ratingbar = (RatingBar) view.findViewById(R.id.ratingbar);
        TextView tv_star = (TextView) view.findViewById(R.id.tv_star);
        tv_time.setText(list.get(i).time);
        tv_star.setText(list.get(i).star + "分");
        ratingbar.setRating(list.get(i).star);
        return view;
    }
}
